<%@page contentType="application/vnd.ms-excel" pageEncoding="UTF-8"%>

<%@ page import="java.util.List,com.vs.model.ExpenseForm" %>

<%
	// application/vnd.ms-excel
	//text/csv
	String fileName = null;
	if (null == request.getAttribute("reportName"))
		fileName = "report";
	else
		fileName = (String) request.getAttribute("reportName");

	response.setHeader("Content-Disposition:", "attachment;filename="
			+ fileName + ".xls");
	
	System.out.println("displaying viewexpense jsp");
%>

<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<html>
<body>
	
	<% 
int total =0;
List<ExpenseForm> list = (List<ExpenseForm>)request.getSession(false).getAttribute("expensesList");
for(int i=0;i<list.size();i++)
{
	total+=Integer.parseInt(list.get(i).getExpenseAmount());
}
%>


	<table cellpadding="3" cellspacing="3" border="1" class="grid">
		<tr>
			<th>Project Name</th>
			<th>Expense Type</th>
			<th>Notes</th>
			<th>Expense Date</th>
			<th>Pay Mode</th>
			<th>Amount</th>
		</tr>
		<logic:present name="expensesList" scope="session">
			<logic:iterate id="element" name="expensesList" scope="session">
				<tr>
					<td><bean:write name="element" property="expenseProjectName" />
					</td>
					<td><bean:write name="element" property="expenseTypeName" />
					</td>
					<td><bean:write name="element" property="notes" /></td>
					<td><bean:write name="element" property="expenseDate" /></td>
					<td><bean:write name="element" property="payMode" /></td>
					<td><bean:write name="element" property="expenseAmount" />
					</td>
				</tr>

			</logic:iterate>
			<tr>
							<td>&nbsp;
							</td>
							<td>&nbsp;
							</td>
							<td>&nbsp;
							</td>
							<td>&nbsp;
							</td>							
							<th class="see_det_font">Total
							</th>
							<th class="see_det_font"><%=total%> Rs
							</th>							
						</tr>
		</logic:present>

	</table>
</body>
</html>